<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.example.simpleforum.model.Post" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
    <title>帖子列表 - 极简论坛</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
    <h1>帖子列表</h1>
    <div class="actions">
        <a href="index.jsp" class="btn">返回首页</a>
        <a href="PostAddServlet" class="btn">发布新帖</a>
    </div>
    <div class="post-list">
        <% 
            List<Post> posts = (List<Post>) request.getAttribute("posts");
            if (posts != null && !posts.isEmpty()) {
                for (Post post : posts) {
        %>
        <div class="post-item">
            <h3><a href="PostDetailServlet?id=<%= post.getId() %>"><%= post.getTitle() %></a></h3>
            <div class="post-meta">
                <span>作者: <%= post.getUsername() %></span>
                <span>发布时间: <%= post.getCreateTime() %></span>
            </div>
        </div>
        <% 
                }
            } else {
        %>
        <p>暂无帖子</p>
        <% } %>
    </div>
</div>
</body>
</html>